/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * 
 * Project Name:itsm-gateway
 * Create Time: 2016年2月16日 下午11:25:00
 */
package com.lenovo.lmrp.server.itsmgateway.test.unit;

import java.io.InputStream;
import java.util.List;

import com.lenovo.lmrp.api.model.entity.AttachmentPO;
import com.lenovo.lmrp.api.model.entity.EngineerPO;
import com.lenovo.lmrp.api.model.entity.TicketPO;
import com.lenovo.lmrp.api.model.view.ChangedTicketVO;
import com.lenovo.lmrp.api.model.view.EngineerVO;
import com.lenovo.lmrp.api.model.view.PartsVO;
import com.lenovo.lmrp.api.model.view.TicketVO;
import com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter;
import com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapterFactory;
import com.lenovo.lmrp.server.itsmgateway.domain.metadata.ItsmEntityTranslator.EntityName;
import com.lenovo.sdc.framework.util.AttributeBean;
import com.lenovo.sdc.framework.util.Tuple;
import com.lenovo.sdc.framework.util.Tuple.Pair;
import com.lenovo.sdc.framework.util.Tuple.Triplet;

/**
 * 
 * @author wujin
 * @version $Id: MockAdapterFactory.java, v 0.1 2016年2月16日 下午11:25:00 wujin Exp $
 */
public class MockAdapterFactory extends AItsmAdapterFactory {

    @Override
    public void initialize() {
    }

    @Override
    protected AItsmAdapter createAdapter(String itsmcode) {
        return new MockItsmAdapter(null);
    }

    static class MockItsmAdapter extends AItsmAdapter {

        /**
         * @param params
         */
        public MockItsmAdapter(AttributeBean params) {
            super(params);
        }

        /** 
         * @see com.lenovo.sdc.framework.mq.IMQReceiver#onMessage(java.lang.String, java.lang.Object)
         */
        @Override
        public void onMessage(String topic, Object content) {
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#authenticate(java.lang.String, java.lang.String)
         */
        @Override
        public Pair<Boolean, String> authenticate(String loginName, String password) {
            if (loginName.equals("testnotexist"))
                return Tuple.makePair(false, "Not this engineer");
            else
                return Tuple.makePair(true, "OK");
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#resetPassword(com.lenovo.lmrp.api.model.view.EngineerVO)
         */
        @Override
        public Pair<Boolean, String> resetPassword(EngineerVO engineer) {
            return null;
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#getEngineer(java.lang.String)
         */
        @Override
        public Triplet<Boolean, String, EngineerPO> getEngineer(String loginName) {
            EngineerPO po = new EngineerPO();
            po.setId(loginName);
            po.setLoginName(loginName);
            po.setCity("beijing");
            po.setEmail("abc@efg.com");
            po.setPhone("110");
            po.setFullName("tester");
            return Tuple.makeTriplet(true, "OK", po);
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#updateEngineer(com.lenovo.lmrp.api.model.view.EngineerVO)
         */
        @Override
        public Pair<Boolean, String> updateEngineer(EngineerVO engineer) {
            return Tuple.makePair(true, "OK");
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#getTicket(java.lang.String)
         */
        @Override
        public Triplet<Boolean, String, TicketPO> getTicket(String ticketID) {
            return null;
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#updateTicket(com.lenovo.lmrp.api.model.view.ChangedTicketVO)
         */
        @Override
        public Pair<Boolean, String> updateTicket(ChangedTicketVO ticket) {
            return Tuple.makePair(true, "OK");
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#replaceParts(java.lang.String, java.util.List)
         */
        @Override
        public Pair<Boolean, String> replaceParts(String ticketID, List<PartsVO> partsList) {
            return null;
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#uploadTicketAttachment(com.lenovo.lmrp.api.model.entity.AttachmentPO)
         */
        @Override
        public Pair<Boolean, String> uploadTicketAttachment(AttachmentPO attachment) {
            System.out.println("mocke to sync uploadTicketAttachment ");
            return Tuple.makePair(true, "OK");
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#createTicket(com.lenovo.lmrp.api.model.view.TicketVO)
         */
        @Override
        public Triplet<Boolean, String, TicketPO> createTicket(TicketVO ticket) {
            return null;
        }

        /** 
         * @see com.lenovo.lmrp.server.itsmgateway.adapter.AItsmAdapter#importEntityData(java.lang.String, java.io.InputStream)
         */
        @Override
        public Pair<Boolean, String> importEntityData(EntityName entity, InputStream input) {
            return null;
        }
        
    }
}
